//
//  PSCalculator.h
//  PrefCore
//
//  Created by Sergey on 2/27/14.
//  Copyright (c) 2014 Play-on-smart. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "PSGame.h"
#import "PSScorer.h"

@interface PSCalculator : NSObject

-(instancetype)initWithPassingScorer:(PSPassingScorer*)passingScorer
          costsPlaySuccess:(NSArray*)costsPlaySuccess
             costsPlayFail:(NSArray*)costsPlayFail
         costsWhistSuccess:(NSArray*)costsWhistSuccess
            costsWhistFail:(NSArray*)costsWhistFail
       normalizationFactor:(uint32_t)normalizationFactor;

/// Obtain a calculator for the specific game flavor.
+(instancetype)calculatorForGameFlavor:(PSGameFlavor)flavor;

/// Check if player is closed.
-(BOOL)isClosed:(PSPlayer*)p game:(PSGame*)game settings:(PSGameSettings*)settings;

/// Check if game is over.
-(BOOL)isGameOver:(PSGame*)game settings:(PSGameSettings*)settings;

/// Get mountain normalization factor.
@property (nonatomic, readonly) uint32_t normalizationFactor;

-(PSScoreValue) playCostSuccessWithTricks:(PSTrickCount)numTricks;

-(PSScoreValue) playCostFailureWithTricks:(PSTrickCount)numTricks;

-(PSScoreValue) whistCostSuccessWithTricks:(PSTrickCount)numTricks;

-(PSScoreValue) whistCostFailureWithTricks:(PSTrickCount)numTricks;

-(PSScoreValue) missedTrickCostWithTricks:(PSTrickCount)numTricks;

/// Write into player's mountain.
-(void)writeToMountainOfPlayer:(PSPlayer*)player
                          game:(PSGame*)game
                         value:(PSScoreValue)value;

/// Write into player's pool.
-(void)writeToPoolOfPlayer:(PSPlayer*)player
                      game:(PSGame*)game
                  settings:(PSGameSettings*)settings
                     value:(PSScoreValue)value;

/// Write whists on another player.
-(void)writeWhistsFromPlayer:(PSPlayer*)fromPlayer
                    toPlayer:(PSPlayer*)toPlayer
                        game:(PSGame*)game
                       value:(PSScoreValue)value;

// Get the number of expected whists for open game type.
+(PSTrickCount)expectedOpenWhistsForContract:(PSTrickCount)contractTricks;

// Get the number of expected whists for blind game type.
+(PSTrickCount)expectedStandingWhistsForContract:(PSTrickCount)contractTricks;

-(void)passingWithGame:(PSGame*)game settings:(PSGameSettings*)settings;

-(void)misereWithGame:(PSGame*)game settings:(PSGameSettings*)settings;

-(void)trickingWithGame:(PSGame*)game settings:(PSGameSettings*)settings;

-(void)trickingTwoPassesWithGame:(PSGame*)game settings:(PSGameSettings*)settings;

-(void)trickingHalfWhistWithGame:(PSGame*)game settings:(PSGameSettings*)settings;

-(void)trickingWithoutThreeWithGame:(PSGame*)game settings:(PSGameSettings*)settings;

-(void)trickingTenWithGame:(PSGame*)game settings:(PSGameSettings*)settings;

@end
